﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Session.cs" company="">
//   Copyright (c) 2010/2011 All Right Reserved
// </copyright>
// <summary>
//   Contains Session class declaration.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace IBupro.Classes
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.SessionState;

    /// <summary>
    /// Implements session management using ASP.NET Sessions.
    /// </summary>
    public class Session
    {
        /// <summary>
        /// ASP.NET session state.
        /// </summary>
        private HttpSessionState session;

        public Session()
        {
            this.session = HttpContext.Current.Session;
        }

        /// <summary>
        /// Access to items stored in session.
        /// </summary>
        /// <param name="name">
        /// Name of value in session.
        /// </param>
        public object this[string name]
        {
            get { return this.session[name]; }
            set { this.session[name] = value; }
        }

        /// <summary>
        /// Sets the value under specified name.
        /// </summary>
        /// <param name="name">The name in session.</param>
        /// <param name="value">The value.</param>
        public void Set(string name, object value)
        {
            this.session[name] = value;
        }

        /// <summary>
        /// Gets the value under specified name.
        /// </summary>
        /// <param name="name">The name in session.</param>
        /// <returns>The object.</returns>
        public object Get(string name)
        {
            return this.session[name];
        }
    }
}